﻿using System;
using UnityEngine;

namespace UnityStandardAssets.CinematicEffects
{
	// Token: 0x020004D8 RID: 1240
	[ExecuteInEditMode]
	[RequireComponent(typeof(Camera))]
	[AddComponentMenu("Image Effects/Cinematic/Tonemapping and Color Grading")]
	[ImageEffectAllowedInSceneView]
	public class TonemappingColorGrading : MonoBehaviour
	{
		// Token: 0x1700020F RID: 527
		// (get) Token: 0x06001924 RID: 6436 RVA: 0x00073601 File Offset: 0x00071A01
		// (set) Token: 0x06001925 RID: 6437 RVA: 0x00073609 File Offset: 0x00071A09
		public TonemappingColorGrading.EyeAdaptationSettings eyeAdaptation
		{
			get
			{
				return this.m_EyeAdaptation;
			}
			set
			{
				this.m_EyeAdaptation = value;
			}
		}

		// Token: 0x17000210 RID: 528
		// (get) Token: 0x06001926 RID: 6438 RVA: 0x00073612 File Offset: 0x00071A12
		// (set) Token: 0x06001927 RID: 6439 RVA: 0x0007361A File Offset: 0x00071A1A
		public TonemappingColorGrading.TonemappingSettings tonemapping
		{
			get
			{
				return this.m_Tonemapping;
			}
			set
			{
				this.m_Tonemapping = value;
				this.SetTonemapperDirty();
			}
		}

		// Token: 0x17000211 RID: 529
		// (get) Token: 0x06001928 RID: 6440 RVA: 0x00073629 File Offset: 0x00071A29
		// (set) Token: 0x06001929 RID: 6441 RVA: 0x00073631 File Offset: 0x00071A31
		public TonemappingColorGrading.ColorGradingSettings colorGrading
		{
			get
			{
				return this.m_ColorGrading;
			}
			set
			{
				this.m_ColorGrading = value;
				this.SetDirty();
			}
		}

		// Token: 0x17000212 RID: 530
		// (get) Token: 0x0600192A RID: 6442 RVA: 0x00073640 File Offset: 0x00071A40
		// (set) Token: 0x0600192B RID: 6443 RVA: 0x00073648 File Offset: 0x00071A48
		public TonemappingColorGrading.LUTSettings lut
		{
			get
			{
				return this.m_Lut;
			}
			set
			{
				this.m_Lut = value;
			}
		}

		// Token: 0x17000213 RID: 531
		// (get) Token: 0x0600192C RID: 6444 RVA: 0x00073654 File Offset: 0x00071A54
		private Texture2D identityLut
		{
			get
			{
				if (this.m_IdentityLut == null || this.m_IdentityLut.height != this.lutSize)
				{
					UnityEngine.Object.DestroyImmediate(this.m_IdentityLut);
					this.m_IdentityLut = TonemappingColorGrading.GenerateIdentityLut(this.lutSize);
				}
				return this.m_IdentityLut;
			}
		}

		// Token: 0x17000214 RID: 532
		// (get) Token: 0x0600192D RID: 6445 RVA: 0x000736AC File Offset: 0x00071AAC
		private RenderTexture internalLutRt
		{
			get
			{
				if (this.m_InternalLut == null || !this.m_InternalLut.IsCreated() || this.m_InternalLut.height != this.lutSize)
				{
					UnityEngine.Object.DestroyImmediate(this.m_InternalLut);
					this.m_InternalLut = new RenderTexture(this.lutSize * this.lutSize, this.lutSize, 0, RenderTextureFormat.ARGB32)
					{
						name = "Internal LUT",
						filterMode = FilterMode.Bilinear,
						anisoLevel = 0,
						hideFlags = HideFlags.DontSave
					};
				}
				return this.m_InternalLut;
			}
		}

		// Token: 0x17000215 RID: 533
		// (get) Token: 0x0600192E RID: 6446 RVA: 0x00073744 File Offset: 0x00071B44
		private Texture2D curveTexture
		{
			get
			{
				if (this.m_CurveTexture == null)
				{
					this.m_CurveTexture = new Texture2D(256, 1, TextureFormat.ARGB32, false, true)
					{
						name = "Curve texture",
						wrapMode = TextureWrapMode.Clamp,
						filterMode = FilterMode.Bilinear,
						anisoLevel = 0,
						hideFlags = HideFlags.DontSave
					};
				}
				return this.m_CurveTexture;
			}
		}

		// Token: 0x17000216 RID: 534
		// (get) Token: 0x0600192F RID: 6447 RVA: 0x000737A8 File Offset: 0x00071BA8
		private Texture2D tonemapperCurve
		{
			get
			{
				if (this.m_TonemapperCurve == null)
				{
					TextureFormat format = TextureFormat.RGB24;
					if (SystemInfo.SupportsTextureFormat(TextureFormat.RFloat))
					{
						format = TextureFormat.RFloat;
					}
					else if (SystemInfo.SupportsTextureFormat(TextureFormat.RHalf))
					{
						format = TextureFormat.RHalf;
					}
					this.m_TonemapperCurve = new Texture2D(256, 1, format, false, true)
					{
						name = "Tonemapper curve texture",
						wrapMode = TextureWrapMode.Clamp,
						filterMode = FilterMode.Bilinear,
						anisoLevel = 0,
						hideFlags = HideFlags.DontSave
					};
				}
				return this.m_TonemapperCurve;
			}
		}

		// Token: 0x17000217 RID: 535
		// (get) Token: 0x06001930 RID: 6448 RVA: 0x0007382F File Offset: 0x00071C2F
		public Shader shader
		{
			get
			{
				if (this.m_Shader == null)
				{
					this.m_Shader = Shader.Find("Hidden/TonemappingColorGrading");
				}
				return this.m_Shader;
			}
		}

		// Token: 0x17000218 RID: 536
		// (get) Token: 0x06001931 RID: 6449 RVA: 0x00073858 File Offset: 0x00071C58
		public Material material
		{
			get
			{
				if (this.m_Material == null)
				{
					this.m_Material = ImageEffectHelper.CheckShaderAndCreateMaterial(this.shader);
				}
				return this.m_Material;
			}
		}

		// Token: 0x17000219 RID: 537
		// (get) Token: 0x06001932 RID: 6450 RVA: 0x00073882 File Offset: 0x00071C82
		public bool isGammaColorSpace
		{
			get
			{
				return QualitySettings.activeColorSpace == ColorSpace.Gamma;
			}
		}

		// Token: 0x1700021A RID: 538
		// (get) Token: 0x06001933 RID: 6451 RVA: 0x0007388C File Offset: 0x00071C8C
		public int lutSize
		{
			get
			{
				return (int)this.colorGrading.precision;
			}
		}

		// Token: 0x1700021B RID: 539
		// (get) Token: 0x06001934 RID: 6452 RVA: 0x000738A7 File Offset: 0x00071CA7
		// (set) Token: 0x06001935 RID: 6453 RVA: 0x000738AF File Offset: 0x00071CAF
		public bool validRenderTextureFormat { get; private set; }

		// Token: 0x1700021C RID: 540
		// (get) Token: 0x06001936 RID: 6454 RVA: 0x000738B8 File Offset: 0x00071CB8
		// (set) Token: 0x06001937 RID: 6455 RVA: 0x000738C0 File Offset: 0x00071CC0
		public bool validUserLutSize { get; private set; }

		// Token: 0x06001938 RID: 6456 RVA: 0x000738C9 File Offset: 0x00071CC9
		public void SetDirty()
		{
			this.m_Dirty = true;
		}

		// Token: 0x06001939 RID: 6457 RVA: 0x000738D2 File Offset: 0x00071CD2
		public void SetTonemapperDirty()
		{
			this.m_TonemapperDirty = true;
		}

		// Token: 0x0600193A RID: 6458 RVA: 0x000738DB File Offset: 0x00071CDB
		private void OnEnable()
		{
			if (!ImageEffectHelper.IsSupported(this.shader, false, true, this))
			{
				base.enabled = false;
				return;
			}
			this.SetDirty();
			this.SetTonemapperDirty();
		}

		// Token: 0x0600193B RID: 6459 RVA: 0x00073904 File Offset: 0x00071D04
		private void OnDisable()
		{
			if (this.m_Material != null)
			{
				UnityEngine.Object.DestroyImmediate(this.m_Material);
			}
			if (this.m_IdentityLut != null)
			{
				UnityEngine.Object.DestroyImmediate(this.m_IdentityLut);
			}
			if (this.m_InternalLut != null)
			{
				UnityEngine.Object.DestroyImmediate(this.internalLutRt);
			}
			if (this.m_SmallAdaptiveRt != null)
			{
				UnityEngine.Object.DestroyImmediate(this.m_SmallAdaptiveRt);
			}
			if (this.m_CurveTexture != null)
			{
				UnityEngine.Object.DestroyImmediate(this.m_CurveTexture);
			}
			if (this.m_TonemapperCurve != null)
			{
				UnityEngine.Object.DestroyImmediate(this.m_TonemapperCurve);
			}
			this.m_Material = null;
			this.m_IdentityLut = null;
			this.m_InternalLut = null;
			this.m_SmallAdaptiveRt = null;
			this.m_CurveTexture = null;
			this.m_TonemapperCurve = null;
		}

		// Token: 0x0600193C RID: 6460 RVA: 0x000739E3 File Offset: 0x00071DE3
		private void OnValidate()
		{
			this.SetDirty();
			this.SetTonemapperDirty();
		}

		// Token: 0x0600193D RID: 6461 RVA: 0x000739F4 File Offset: 0x00071DF4
		private static Texture2D GenerateIdentityLut(int dim)
		{
			Color[] array = new Color[dim * dim * dim];
			float num = 1f / ((float)dim - 1f);
			for (int i = 0; i < dim; i++)
			{
				for (int j = 0; j < dim; j++)
				{
					for (int k = 0; k < dim; k++)
					{
						array[i + j * dim + k * dim * dim] = new Color((float)i * num, Mathf.Abs((float)k * num), (float)j * num, 1f);
					}
				}
			}
			Texture2D texture2D = new Texture2D(dim * dim, dim, TextureFormat.RGB24, false, true)
			{
				name = "Identity LUT",
				filterMode = FilterMode.Bilinear,
				anisoLevel = 0,
				hideFlags = HideFlags.DontSave
			};
			texture2D.SetPixels(array);
			texture2D.Apply();
			return texture2D;
		}

		// Token: 0x0600193E RID: 6462 RVA: 0x00073AD0 File Offset: 0x00071ED0
		private float StandardIlluminantY(float x)
		{
			return 2.87f * x - 3f * x * x - 0.27509508f;
		}

		// Token: 0x0600193F RID: 6463 RVA: 0x00073AEC File Offset: 0x00071EEC
		private Vector3 CIExyToLMS(float x, float y)
		{
			float num = 1f;
			float num2 = num * x / y;
			float num3 = num * (1f - x - y) / y;
			float x2 = 0.7328f * num2 + 0.4296f * num - 0.1624f * num3;
			float y2 = -0.7036f * num2 + 1.6975f * num + 0.0061f * num3;
			float z = 0.003f * num2 + 0.0136f * num + 0.9834f * num3;
			return new Vector3(x2, y2, z);
		}

		// Token: 0x06001940 RID: 6464 RVA: 0x00073B68 File Offset: 0x00071F68
		private Vector3 GetWhiteBalance()
		{
			float temperatureShift = this.colorGrading.basics.temperatureShift;
			float tint = this.colorGrading.basics.tint;
			float x = 0.31271f - temperatureShift * ((temperatureShift >= 0f) ? 0.05f : 0.1f);
			float y = this.StandardIlluminantY(x) + tint * 0.05f;
			Vector3 vector = new Vector3(0.949237f, 1.03542f, 1.08728f);
			Vector3 vector2 = this.CIExyToLMS(x, y);
			return new Vector3(vector.x / vector2.x, vector.y / vector2.y, vector.z / vector2.z);
		}

		// Token: 0x06001941 RID: 6465 RVA: 0x00073C28 File Offset: 0x00072028
		private static Color NormalizeColor(Color c)
		{
			float num = (c.r + c.g + c.b) / 3f;
			if (Mathf.Approximately(num, 0f))
			{
				return new Color(1f, 1f, 1f, 1f);
			}
			return new Color
			{
				r = c.r / num,
				g = c.g / num,
				b = c.b / num,
				a = 1f
			};
		}

		// Token: 0x06001942 RID: 6466 RVA: 0x00073CC4 File Offset: 0x000720C4
		private void GenerateLiftGammaGain(out Color lift, out Color gamma, out Color gain)
		{
			Color color = TonemappingColorGrading.NormalizeColor(this.colorGrading.colorWheels.shadows);
			Color color2 = TonemappingColorGrading.NormalizeColor(this.colorGrading.colorWheels.midtones);
			Color color3 = TonemappingColorGrading.NormalizeColor(this.colorGrading.colorWheels.highlights);
			float num = (color.r + color.g + color.b) / 3f;
			float num2 = (color2.r + color2.g + color2.b) / 3f;
			float num3 = (color3.r + color3.g + color3.b) / 3f;
			float r = (color.r - num) * 0.1f;
			float g = (color.g - num) * 0.1f;
			float b = (color.b - num) * 0.1f;
			float b2 = Mathf.Pow(2f, (color2.r - num2) * 0.5f);
			float b3 = Mathf.Pow(2f, (color2.g - num2) * 0.5f);
			float b4 = Mathf.Pow(2f, (color2.b - num2) * 0.5f);
			float r2 = Mathf.Pow(2f, (color3.r - num3) * 0.5f);
			float g2 = Mathf.Pow(2f, (color3.g - num3) * 0.5f);
			float b5 = Mathf.Pow(2f, (color3.b - num3) * 0.5f);
			float r3 = 1f / Mathf.Max(0.01f, b2);
			float g3 = 1f / Mathf.Max(0.01f, b3);
			float b6 = 1f / Mathf.Max(0.01f, b4);
			lift = new Color(r, g, b);
			gamma = new Color(r3, g3, b6);
			gain = new Color(r2, g2, b5);
		}

		// Token: 0x06001943 RID: 6467 RVA: 0x00073EBC File Offset: 0x000722BC
		private void GenCurveTexture()
		{
			AnimationCurve master = this.colorGrading.curves.master;
			AnimationCurve red = this.colorGrading.curves.red;
			AnimationCurve green = this.colorGrading.curves.green;
			AnimationCurve blue = this.colorGrading.curves.blue;
			Color[] array = new Color[256];
			for (float num = 0f; num <= 1f; num += 0.003921569f)
			{
				float a = Mathf.Clamp(master.Evaluate(num), 0f, 1f);
				float r = Mathf.Clamp(red.Evaluate(num), 0f, 1f);
				float g = Mathf.Clamp(green.Evaluate(num), 0f, 1f);
				float b = Mathf.Clamp(blue.Evaluate(num), 0f, 1f);
				array[(int)Mathf.Floor(num * 255f)] = new Color(r, g, b, a);
			}
			this.curveTexture.SetPixels(array);
			this.curveTexture.Apply();
		}

		// Token: 0x06001944 RID: 6468 RVA: 0x00073FF0 File Offset: 0x000723F0
		private bool CheckUserLut()
		{
			this.validUserLutSize = (this.lut.texture.height == (int)Mathf.Sqrt((float)this.lut.texture.width));
			return this.validUserLutSize;
		}

		// Token: 0x06001945 RID: 6469 RVA: 0x00074038 File Offset: 0x00072438
		private bool CheckSmallAdaptiveRt()
		{
			if (this.m_SmallAdaptiveRt != null)
			{
				return false;
			}
			this.m_AdaptiveRtFormat = RenderTextureFormat.ARGBHalf;
			if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RGHalf))
			{
				this.m_AdaptiveRtFormat = RenderTextureFormat.RGHalf;
			}
			this.m_SmallAdaptiveRt = new RenderTexture(1, 1, 0, this.m_AdaptiveRtFormat);
			this.m_SmallAdaptiveRt.hideFlags = HideFlags.DontSave;
			return true;
		}

		// Token: 0x06001946 RID: 6470 RVA: 0x00074098 File Offset: 0x00072498
		private void OnGUI()
		{
			if (Event.current.type != EventType.Repaint)
			{
				return;
			}
			int num = 0;
			if (this.m_InternalLut != null && this.colorGrading.enabled && this.colorGrading.showDebug)
			{
				Graphics.DrawTexture(new Rect(0f, (float)num, (float)(this.lutSize * this.lutSize), (float)this.lutSize), this.internalLutRt);
				num += this.lutSize;
			}
			if (this.m_SmallAdaptiveRt != null && this.eyeAdaptation.enabled && this.eyeAdaptation.showDebug)
			{
				this.m_Material.SetPass(12);
				Graphics.DrawTexture(new Rect(0f, (float)num, 256f, 16f), this.m_SmallAdaptiveRt, this.m_Material);
			}
		}

		// Token: 0x06001947 RID: 6471 RVA: 0x00074194 File Offset: 0x00072594
		[ImageEffectTransformsToLDR]
		private void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			this.material.shaderKeywords = null;
			RenderTexture renderTexture = null;
			RenderTexture[] array = null;
			if (this.eyeAdaptation.enabled)
			{
				bool flag = this.CheckSmallAdaptiveRt();
				int num = (source.width >= source.height) ? source.height : source.width;
				int num2 = num;
				num2 |= num2 >> 1;
				num2 |= num2 >> 2;
				num2 |= num2 >> 4;
				num2 |= num2 >> 8;
				num2 |= num2 >> 16;
				num2 -= num2 >> 1;
				renderTexture = RenderTexture.GetTemporary(num2, num2, 0, this.m_AdaptiveRtFormat);
				Graphics.Blit(source, renderTexture);
				int num3 = (int)Mathf.Log((float)renderTexture.width, 2f);
				int num4 = 2;
				array = new RenderTexture[num3];
				for (int i = 0; i < num3; i++)
				{
					array[i] = RenderTexture.GetTemporary(renderTexture.width / num4, renderTexture.width / num4, 0, this.m_AdaptiveRtFormat);
					num4 <<= 1;
				}
				RenderTexture source2 = array[num3 - 1];
				Graphics.Blit(renderTexture, array[0], this.material, 1);
				for (int j = 0; j < num3 - 1; j++)
				{
					Graphics.Blit(array[j], array[j + 1]);
					source2 = array[j + 1];
				}
				this.m_SmallAdaptiveRt.MarkRestoreExpected();
				this.material.SetFloat("_AdaptationSpeed", Mathf.Max(this.eyeAdaptation.speed, 0.001f));
				Graphics.Blit(source2, this.m_SmallAdaptiveRt, this.material, (!flag) ? 2 : 3);
				this.material.SetFloat("_MiddleGrey", this.eyeAdaptation.middleGrey);
				this.material.SetFloat("_AdaptationMin", Mathf.Pow(2f, this.eyeAdaptation.min));
				this.material.SetFloat("_AdaptationMax", Mathf.Pow(2f, this.eyeAdaptation.max));
				this.material.SetTexture("_LumTex", this.m_SmallAdaptiveRt);
				this.material.EnableKeyword("ENABLE_EYE_ADAPTATION");
			}
			int num5 = 4;
			if (this.tonemapping.enabled)
			{
				if (this.tonemapping.tonemapper == TonemappingColorGrading.Tonemapper.Curve)
				{
					if (this.m_TonemapperDirty)
					{
						float num6 = 1f;
						if (this.tonemapping.curve.length > 0)
						{
							num6 = this.tonemapping.curve[this.tonemapping.curve.length - 1].time;
							for (float num7 = 0f; num7 <= 1f; num7 += 0.003921569f)
							{
								float num8 = this.tonemapping.curve.Evaluate(num7 * num6);
								this.tonemapperCurve.SetPixel(Mathf.FloorToInt(num7 * 255f), 0, new Color(num8, num8, num8));
							}
							this.tonemapperCurve.Apply();
						}
						this.m_TonemapperCurveRange = 1f / num6;
						this.m_TonemapperDirty = false;
					}
					this.material.SetFloat("_ToneCurveRange", this.m_TonemapperCurveRange);
					this.material.SetTexture("_ToneCurve", this.tonemapperCurve);
				}
				else if (this.tonemapping.tonemapper == TonemappingColorGrading.Tonemapper.Neutral)
				{
					float num9 = this.tonemapping.neutralBlackIn * 20f + 1f;
					float num10 = this.tonemapping.neutralBlackOut * 10f + 1f;
					float num11 = this.tonemapping.neutralWhiteIn / 20f;
					float num12 = 1f - this.tonemapping.neutralWhiteOut / 20f;
					float t = num9 / num10;
					float t2 = num11 / num12;
					float y = Mathf.Max(0f, Mathf.LerpUnclamped(0.57f, 0.37f, t));
					float z = Mathf.LerpUnclamped(0.01f, 0.24f, t2);
					float w = Mathf.Max(0f, Mathf.LerpUnclamped(0.02f, 0.2f, t));
					this.material.SetVector("_NeutralTonemapperParams1", new Vector4(0.2f, y, z, w));
					this.material.SetVector("_NeutralTonemapperParams2", new Vector4(0.02f, 0.3f, this.tonemapping.neutralWhiteLevel, this.tonemapping.neutralWhiteClip / 10f));
				}
				this.material.SetFloat("_Exposure", this.tonemapping.exposure);
				num5 = (int)(num5 + (this.tonemapping.tonemapper + 1));
			}
			if (this.colorGrading.enabled)
			{
				if (this.m_Dirty || !this.m_InternalLut.IsCreated())
				{
					Color c;
					Color c2;
					Color c3;
					this.GenerateLiftGammaGain(out c, out c2, out c3);
					this.GenCurveTexture();
					this.material.SetVector("_WhiteBalance", this.GetWhiteBalance());
					this.material.SetVector("_Lift", c);
					this.material.SetVector("_Gamma", c2);
					this.material.SetVector("_Gain", c3);
					this.material.SetVector("_ContrastGainGamma", new Vector3(this.colorGrading.basics.contrast, this.colorGrading.basics.gain, 1f / this.colorGrading.basics.gamma));
					this.material.SetFloat("_Vibrance", this.colorGrading.basics.vibrance);
					this.material.SetVector("_HSV", new Vector4(this.colorGrading.basics.hue, this.colorGrading.basics.saturation, this.colorGrading.basics.value));
					this.material.SetVector("_ChannelMixerRed", this.colorGrading.channelMixer.channels[0]);
					this.material.SetVector("_ChannelMixerGreen", this.colorGrading.channelMixer.channels[1]);
					this.material.SetVector("_ChannelMixerBlue", this.colorGrading.channelMixer.channels[2]);
					this.material.SetTexture("_CurveTex", this.curveTexture);
					this.internalLutRt.MarkRestoreExpected();
					Graphics.Blit(this.identityLut, this.internalLutRt, this.material, 0);
					this.m_Dirty = false;
				}
				this.material.EnableKeyword("ENABLE_COLOR_GRADING");
				if (this.colorGrading.useDithering)
				{
					this.material.EnableKeyword("ENABLE_DITHERING");
				}
				this.material.SetTexture("_InternalLutTex", this.internalLutRt);
				this.material.SetVector("_InternalLutParams", new Vector3(1f / (float)this.internalLutRt.width, 1f / (float)this.internalLutRt.height, (float)this.internalLutRt.height - 1f));
			}
			if (this.lut.enabled && this.lut.texture != null && this.CheckUserLut())
			{
				this.material.SetTexture("_UserLutTex", this.lut.texture);
				this.material.SetVector("_UserLutParams", new Vector4(1f / (float)this.lut.texture.width, 1f / (float)this.lut.texture.height, (float)this.lut.texture.height - 1f, this.lut.contribution));
				this.material.EnableKeyword("ENABLE_USER_LUT");
			}
			Graphics.Blit(source, destination, this.material, num5);
			if (this.eyeAdaptation.enabled)
			{
				for (int k = 0; k < array.Length; k++)
				{
					RenderTexture.ReleaseTemporary(array[k]);
				}
				RenderTexture.ReleaseTemporary(renderTexture);
			}
		}

		// Token: 0x06001948 RID: 6472 RVA: 0x00074A98 File Offset: 0x00072E98
		public Texture2D BakeLUT()
		{
			Texture2D texture2D = new Texture2D(this.internalLutRt.width, this.internalLutRt.height, TextureFormat.RGB24, false, true);
			RenderTexture.active = this.internalLutRt;
			texture2D.ReadPixels(new Rect(0f, 0f, (float)texture2D.width, (float)texture2D.height), 0, 0);
			RenderTexture.active = null;
			return texture2D;
		}

		// Token: 0x0400103C RID: 4156
		[SerializeField]
		[TonemappingColorGrading.SettingsGroup]
		private TonemappingColorGrading.EyeAdaptationSettings m_EyeAdaptation = TonemappingColorGrading.EyeAdaptationSettings.defaultSettings;

		// Token: 0x0400103D RID: 4157
		[SerializeField]
		[TonemappingColorGrading.SettingsGroup]
		private TonemappingColorGrading.TonemappingSettings m_Tonemapping = TonemappingColorGrading.TonemappingSettings.defaultSettings;

		// Token: 0x0400103E RID: 4158
		[SerializeField]
		[TonemappingColorGrading.SettingsGroup]
		private TonemappingColorGrading.ColorGradingSettings m_ColorGrading = TonemappingColorGrading.ColorGradingSettings.defaultSettings;

		// Token: 0x0400103F RID: 4159
		[SerializeField]
		[TonemappingColorGrading.SettingsGroup]
		private TonemappingColorGrading.LUTSettings m_Lut = TonemappingColorGrading.LUTSettings.defaultSettings;

		// Token: 0x04001040 RID: 4160
		private Texture2D m_IdentityLut;

		// Token: 0x04001041 RID: 4161
		private RenderTexture m_InternalLut;

		// Token: 0x04001042 RID: 4162
		private Texture2D m_CurveTexture;

		// Token: 0x04001043 RID: 4163
		private Texture2D m_TonemapperCurve;

		// Token: 0x04001044 RID: 4164
		private float m_TonemapperCurveRange;

		// Token: 0x04001045 RID: 4165
		[SerializeField]
		private Shader m_Shader;

		// Token: 0x04001046 RID: 4166
		private Material m_Material;

		// Token: 0x04001049 RID: 4169
		private bool m_Dirty = true;

		// Token: 0x0400104A RID: 4170
		private bool m_TonemapperDirty = true;

		// Token: 0x0400104B RID: 4171
		private RenderTexture m_SmallAdaptiveRt;

		// Token: 0x0400104C RID: 4172
		private RenderTextureFormat m_AdaptiveRtFormat;

		// Token: 0x020004D9 RID: 1241
		[AttributeUsage(AttributeTargets.Field)]
		public class SettingsGroup : Attribute
		{
		}

		// Token: 0x020004DA RID: 1242
		public class IndentedGroup : PropertyAttribute
		{
		}

		// Token: 0x020004DB RID: 1243
		public class ChannelMixer : PropertyAttribute
		{
		}

		// Token: 0x020004DC RID: 1244
		public class ColorWheelGroup : PropertyAttribute
		{
			// Token: 0x0600194C RID: 6476 RVA: 0x00074B13 File Offset: 0x00072F13
			public ColorWheelGroup()
			{
			}

			// Token: 0x0600194D RID: 6477 RVA: 0x00074B2E File Offset: 0x00072F2E
			public ColorWheelGroup(int minSizePerWheel, int maxSizePerWheel)
			{
				this.minSizePerWheel = minSizePerWheel;
				this.maxSizePerWheel = maxSizePerWheel;
			}

			// Token: 0x0400104D RID: 4173
			public int minSizePerWheel = 60;

			// Token: 0x0400104E RID: 4174
			public int maxSizePerWheel = 150;
		}

		// Token: 0x020004DD RID: 1245
		public class Curve : PropertyAttribute
		{
			// Token: 0x0600194E RID: 6478 RVA: 0x00074B57 File Offset: 0x00072F57
			public Curve()
			{
			}

			// Token: 0x0600194F RID: 6479 RVA: 0x00074B6A File Offset: 0x00072F6A
			public Curve(float r, float g, float b, float a)
			{
				this.color = new Color(r, g, b, a);
			}

			// Token: 0x0400104F RID: 4175
			public Color color = Color.white;
		}

		// Token: 0x020004DE RID: 1246
		[Serializable]
		public struct EyeAdaptationSettings
		{
			// Token: 0x1700021D RID: 541
			// (get) Token: 0x06001950 RID: 6480 RVA: 0x00074B90 File Offset: 0x00072F90
			public static TonemappingColorGrading.EyeAdaptationSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.EyeAdaptationSettings
					{
						enabled = false,
						showDebug = false,
						middleGrey = 0.5f,
						min = -3f,
						max = 3f,
						speed = 1.5f
					};
				}
			}

			// Token: 0x04001050 RID: 4176
			public bool enabled;

			// Token: 0x04001051 RID: 4177
			[Min(0f)]
			[Tooltip("Midpoint Adjustment.")]
			public float middleGrey;

			// Token: 0x04001052 RID: 4178
			[Tooltip("The lowest possible exposure value; adjust this value to modify the brightest areas of your level.")]
			public float min;

			// Token: 0x04001053 RID: 4179
			[Tooltip("The highest possible exposure value; adjust this value to modify the darkest areas of your level.")]
			public float max;

			// Token: 0x04001054 RID: 4180
			[Min(0f)]
			[Tooltip("Speed of linear adaptation. Higher is faster.")]
			public float speed;

			// Token: 0x04001055 RID: 4181
			[Tooltip("Displays a luminosity helper in the GameView.")]
			public bool showDebug;
		}

		// Token: 0x020004DF RID: 1247
		public enum Tonemapper
		{
			// Token: 0x04001057 RID: 4183
			ACES,
			// Token: 0x04001058 RID: 4184
			Curve,
			// Token: 0x04001059 RID: 4185
			Hable,
			// Token: 0x0400105A RID: 4186
			HejlDawson,
			// Token: 0x0400105B RID: 4187
			Photographic,
			// Token: 0x0400105C RID: 4188
			Reinhard,
			// Token: 0x0400105D RID: 4189
			Neutral
		}

		// Token: 0x020004E0 RID: 1248
		[Serializable]
		public struct TonemappingSettings
		{
			// Token: 0x1700021E RID: 542
			// (get) Token: 0x06001951 RID: 6481 RVA: 0x00074BE8 File Offset: 0x00072FE8
			public static TonemappingColorGrading.TonemappingSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.TonemappingSettings
					{
						enabled = false,
						tonemapper = TonemappingColorGrading.Tonemapper.Neutral,
						exposure = 1f,
						curve = TonemappingColorGrading.CurvesSettings.defaultCurve,
						neutralBlackIn = 0.02f,
						neutralWhiteIn = 10f,
						neutralBlackOut = 0f,
						neutralWhiteOut = 10f,
						neutralWhiteLevel = 5.3f,
						neutralWhiteClip = 10f
					};
				}
			}

			// Token: 0x0400105E RID: 4190
			public bool enabled;

			// Token: 0x0400105F RID: 4191
			[Tooltip("Tonemapping technique to use. ACES is the recommended one.")]
			public TonemappingColorGrading.Tonemapper tonemapper;

			// Token: 0x04001060 RID: 4192
			[Min(0f)]
			[Tooltip("Adjusts the overall exposure of the scene.")]
			public float exposure;

			// Token: 0x04001061 RID: 4193
			[Tooltip("Custom tonemapping curve.")]
			public AnimationCurve curve;

			// Token: 0x04001062 RID: 4194
			[Range(-0.1f, 0.1f)]
			public float neutralBlackIn;

			// Token: 0x04001063 RID: 4195
			[Range(1f, 20f)]
			public float neutralWhiteIn;

			// Token: 0x04001064 RID: 4196
			[Range(-0.09f, 0.1f)]
			public float neutralBlackOut;

			// Token: 0x04001065 RID: 4197
			[Range(1f, 19f)]
			public float neutralWhiteOut;

			// Token: 0x04001066 RID: 4198
			[Range(0.1f, 20f)]
			public float neutralWhiteLevel;

			// Token: 0x04001067 RID: 4199
			[Range(1f, 10f)]
			public float neutralWhiteClip;
		}

		// Token: 0x020004E1 RID: 1249
		[Serializable]
		public struct LUTSettings
		{
			// Token: 0x1700021F RID: 543
			// (get) Token: 0x06001952 RID: 6482 RVA: 0x00074C70 File Offset: 0x00073070
			public static TonemappingColorGrading.LUTSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.LUTSettings
					{
						enabled = false,
						texture = null,
						contribution = 1f
					};
				}
			}

			// Token: 0x04001068 RID: 4200
			public bool enabled;

			// Token: 0x04001069 RID: 4201
			[Tooltip("Custom lookup texture (strip format, e.g. 256x16).")]
			public Texture texture;

			// Token: 0x0400106A RID: 4202
			[Range(0f, 1f)]
			[Tooltip("Blending factor.")]
			public float contribution;
		}

		// Token: 0x020004E2 RID: 1250
		[Serializable]
		public struct ColorWheelsSettings
		{
			// Token: 0x17000220 RID: 544
			// (get) Token: 0x06001953 RID: 6483 RVA: 0x00074CA4 File Offset: 0x000730A4
			public static TonemappingColorGrading.ColorWheelsSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.ColorWheelsSettings
					{
						shadows = Color.white,
						midtones = Color.white,
						highlights = Color.white
					};
				}
			}

			// Token: 0x0400106B RID: 4203
			[ColorUsage(false)]
			public Color shadows;

			// Token: 0x0400106C RID: 4204
			[ColorUsage(false)]
			public Color midtones;

			// Token: 0x0400106D RID: 4205
			[ColorUsage(false)]
			public Color highlights;
		}

		// Token: 0x020004E3 RID: 1251
		[Serializable]
		public struct BasicsSettings
		{
			// Token: 0x17000221 RID: 545
			// (get) Token: 0x06001954 RID: 6484 RVA: 0x00074CE0 File Offset: 0x000730E0
			public static TonemappingColorGrading.BasicsSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.BasicsSettings
					{
						temperatureShift = 0f,
						tint = 0f,
						contrast = 1f,
						hue = 0f,
						saturation = 1f,
						value = 1f,
						vibrance = 0f,
						gain = 1f,
						gamma = 1f
					};
				}
			}

			// Token: 0x0400106E RID: 4206
			[Range(-2f, 2f)]
			[Tooltip("Sets the white balance to a custom color temperature.")]
			public float temperatureShift;

			// Token: 0x0400106F RID: 4207
			[Range(-2f, 2f)]
			[Tooltip("Sets the white balance to compensate for a green or magenta tint.")]
			public float tint;

			// Token: 0x04001070 RID: 4208
			[Space]
			[Range(-0.5f, 0.5f)]
			[Tooltip("Shift the hue of all colors.")]
			public float hue;

			// Token: 0x04001071 RID: 4209
			[Range(0f, 2f)]
			[Tooltip("Pushes the intensity of all colors.")]
			public float saturation;

			// Token: 0x04001072 RID: 4210
			[Range(-1f, 1f)]
			[Tooltip("Adjusts the saturation so that clipping is minimized as colors approach full saturation.")]
			public float vibrance;

			// Token: 0x04001073 RID: 4211
			[Range(0f, 10f)]
			[Tooltip("Brightens or darkens all colors.")]
			public float value;

			// Token: 0x04001074 RID: 4212
			[Space]
			[Range(0f, 2f)]
			[Tooltip("Expands or shrinks the overall range of tonal values.")]
			public float contrast;

			// Token: 0x04001075 RID: 4213
			[Range(0.01f, 5f)]
			[Tooltip("Contrast gain curve. Controls the steepness of the curve.")]
			public float gain;

			// Token: 0x04001076 RID: 4214
			[Range(0.01f, 5f)]
			[Tooltip("Applies a pow function to the source.")]
			public float gamma;
		}

		// Token: 0x020004E4 RID: 1252
		[Serializable]
		public struct ChannelMixerSettings
		{
			// Token: 0x17000222 RID: 546
			// (get) Token: 0x06001955 RID: 6485 RVA: 0x00074D64 File Offset: 0x00073164
			public static TonemappingColorGrading.ChannelMixerSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.ChannelMixerSettings
					{
						currentChannel = 0,
						channels = new Vector3[]
						{
							new Vector3(1f, 0f, 0f),
							new Vector3(0f, 1f, 0f),
							new Vector3(0f, 0f, 1f)
						}
					};
				}
			}

			// Token: 0x04001077 RID: 4215
			public int currentChannel;

			// Token: 0x04001078 RID: 4216
			public Vector3[] channels;
		}

		// Token: 0x020004E5 RID: 1253
		[Serializable]
		public struct CurvesSettings
		{
			// Token: 0x17000223 RID: 547
			// (get) Token: 0x06001956 RID: 6486 RVA: 0x00074DF0 File Offset: 0x000731F0
			public static TonemappingColorGrading.CurvesSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.CurvesSettings
					{
						master = TonemappingColorGrading.CurvesSettings.defaultCurve,
						red = TonemappingColorGrading.CurvesSettings.defaultCurve,
						green = TonemappingColorGrading.CurvesSettings.defaultCurve,
						blue = TonemappingColorGrading.CurvesSettings.defaultCurve
					};
				}
			}

			// Token: 0x17000224 RID: 548
			// (get) Token: 0x06001957 RID: 6487 RVA: 0x00074E38 File Offset: 0x00073238
			public static AnimationCurve defaultCurve
			{
				get
				{
					return new AnimationCurve(new Keyframe[]
					{
						new Keyframe(0f, 0f, 1f, 1f),
						new Keyframe(1f, 1f, 1f, 1f)
					});
				}
			}

			// Token: 0x04001079 RID: 4217
			[TonemappingColorGrading.Curve]
			public AnimationCurve master;

			// Token: 0x0400107A RID: 4218
			[TonemappingColorGrading.Curve(1f, 0f, 0f, 1f)]
			public AnimationCurve red;

			// Token: 0x0400107B RID: 4219
			[TonemappingColorGrading.Curve(0f, 1f, 0f, 1f)]
			public AnimationCurve green;

			// Token: 0x0400107C RID: 4220
			[TonemappingColorGrading.Curve(0f, 1f, 1f, 1f)]
			public AnimationCurve blue;
		}

		// Token: 0x020004E6 RID: 1254
		public enum ColorGradingPrecision
		{
			// Token: 0x0400107E RID: 4222
			Normal = 16,
			// Token: 0x0400107F RID: 4223
			High = 32
		}

		// Token: 0x020004E7 RID: 1255
		[Serializable]
		public struct ColorGradingSettings
		{
			// Token: 0x17000225 RID: 549
			// (get) Token: 0x06001958 RID: 6488 RVA: 0x00074E9C File Offset: 0x0007329C
			public static TonemappingColorGrading.ColorGradingSettings defaultSettings
			{
				get
				{
					return new TonemappingColorGrading.ColorGradingSettings
					{
						enabled = false,
						useDithering = false,
						showDebug = false,
						precision = TonemappingColorGrading.ColorGradingPrecision.Normal,
						colorWheels = TonemappingColorGrading.ColorWheelsSettings.defaultSettings,
						basics = TonemappingColorGrading.BasicsSettings.defaultSettings,
						channelMixer = TonemappingColorGrading.ChannelMixerSettings.defaultSettings,
						curves = TonemappingColorGrading.CurvesSettings.defaultSettings
					};
				}
			}

			// Token: 0x06001959 RID: 6489 RVA: 0x00074F03 File Offset: 0x00073303
			internal void Reset()
			{
				this.curves = TonemappingColorGrading.CurvesSettings.defaultSettings;
			}

			// Token: 0x04001080 RID: 4224
			public bool enabled;

			// Token: 0x04001081 RID: 4225
			[Tooltip("Internal LUT precision. \"Normal\" is 256x16, \"High\" is 1024x32. Prefer \"Normal\" on mobile devices.")]
			public TonemappingColorGrading.ColorGradingPrecision precision;

			// Token: 0x04001082 RID: 4226
			[Space]
			[TonemappingColorGrading.ColorWheelGroup]
			public TonemappingColorGrading.ColorWheelsSettings colorWheels;

			// Token: 0x04001083 RID: 4227
			[Space]
			[TonemappingColorGrading.IndentedGroup]
			public TonemappingColorGrading.BasicsSettings basics;

			// Token: 0x04001084 RID: 4228
			[Space]
			[TonemappingColorGrading.ChannelMixer]
			public TonemappingColorGrading.ChannelMixerSettings channelMixer;

			// Token: 0x04001085 RID: 4229
			[Space]
			[TonemappingColorGrading.IndentedGroup]
			public TonemappingColorGrading.CurvesSettings curves;

			// Token: 0x04001086 RID: 4230
			[Space]
			[Tooltip("Use dithering to try and minimize color banding in dark areas.")]
			public bool useDithering;

			// Token: 0x04001087 RID: 4231
			[Tooltip("Displays the generated LUT in the top left corner of the GameView.")]
			public bool showDebug;
		}

		// Token: 0x020004E8 RID: 1256
		private enum Pass
		{
			// Token: 0x04001089 RID: 4233
			LutGen,
			// Token: 0x0400108A RID: 4234
			AdaptationLog,
			// Token: 0x0400108B RID: 4235
			AdaptationExpBlend,
			// Token: 0x0400108C RID: 4236
			AdaptationExp,
			// Token: 0x0400108D RID: 4237
			TonemappingOff,
			// Token: 0x0400108E RID: 4238
			TonemappingACES,
			// Token: 0x0400108F RID: 4239
			TonemappingCurve,
			// Token: 0x04001090 RID: 4240
			TonemappingHable,
			// Token: 0x04001091 RID: 4241
			TonemappingHejlDawson,
			// Token: 0x04001092 RID: 4242
			TonemappingPhotographic,
			// Token: 0x04001093 RID: 4243
			TonemappingReinhard,
			// Token: 0x04001094 RID: 4244
			TonemappingNeutral,
			// Token: 0x04001095 RID: 4245
			AdaptationDebug
		}
	}
}
